package com.cnbot.toolkit.log.zlog;

import android.util.Log;

import java.util.concurrent.LinkedBlockingQueue;

/**
 *  @项目名：  Test
 *  @包名：    com.cnbot.test.zlog
 *  @文件名:   LogQueue
 *  @创建者:   ww
 *  @创建时间:  2019/5/29 14:22
 *  @描述：    日志队列
 */
public class LogQueue {

	private static final String TAG = "LogQueue";
	private LinkedBlockingQueue<LogBean> mLogQueue = new LinkedBlockingQueue(1000);

	LogQueue() {

	}

	void add(final LogBean logBean) {
		boolean offered = false;
		try {
			offered = this.mLogQueue.offer(logBean);
		} catch (Exception var3) {
			Log.e(TAG, "add: ", var3);
		}
		if (offered) {
			return;
		}
		LogThreadPools.getInstance().blockThreadFactoryPool.execute(new Runnable() {
			@Override
			public void run() {
				try {
					LogQueue.this.mLogQueue.put(logBean);
					Log.e(TAG, Thread.currentThread().getName());
				} catch (InterruptedException var2) {
					Log.e(TAG, "run: ", var2);
				}
			}
		});
	}

	public LinkedBlockingQueue<LogBean> getBlockingQueue() {
		return mLogQueue;
	}
}
